<template>
  <uni-popup ref="popup" type="bottom" :class="showStr" :safe-area="false" @maskClick="cancel">
    <view class="content">
      <view class="title">
        <view>
          <text>{{ titleData }}</text>
        </view>
        <image src="/static/icon/info.png"></image>
      </view>
      <view class="c1">
        <slot></slot>
      </view>
      <view style="height: 40px;"></view>
    </view>
  </uni-popup>
</template>
  <script>
export default {
  props: {
    title: { type: String, default: "消息" },
    show: { type: Boolean, default: false }
  },
  data() {
    return {
      btnData: this.ok,
      titleData: this.title,
      showStr: this.show ? 'show' : 'hide',
    }
  },
  beforeMount() {
    this.titleData = this.title;
    this.btnData = this.btn;
  },
  watch: {
    btn: {
      handler(val) {
        this.btnData = val;
      },
      deep: true,
      immedaite: true
    },
    title: {
      handler(val) {
        this.titleData = val;
      },
      deep: true,
      immedaite: true
    },
    show: {
      handler(val) {
        if (val) {
          // uni.hideTabBar();
          this.$refs.popup.open();
        } else {
          try{
            // uni.showTabBar();
            this.$refs.popup.close();

          }catch{
          }
        }
        this.setShow(val);
      },
      deep: true,
      immedaite: true
    }
  },
  methods: {
    okEvent() {
      this.setShow(false);
      this.$emit("ok");
    },
    setShow(val) {
      this.showStr = val ? 'show' : 'hide';
    },
    cancel() {
      this.$emit("cancel");
    }
  }
}
</script>
  
<style scoped lang="scss">
@mixin main() {
  z-index: 999;
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.4);
}
.hide {
    @include main();
    display: none;
  }
  .show {
    @include main();
    display: flex;
  }
.content {
  background-color: #fff;
  width: 100%;
  padding-bottom: 20rpx;
  position: relative;
  .title {
    position: relative;
    padding: 50rpx 20rpx;
    font-size: 16px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight: 400;
    text-align: left;
    color: #2b2b2b;
    line-height: 80rpx;
    display: flex;
    justify-content: space-between;
    view {
      position: absolute;
      left: 0;
      top: 20rpx;
      width: 100%;
      text-align: center;
    }
    image {
      position: absolute;
      right: 20rpx;
      top: 35rpx;
      width: 24px;
      height: 24px;
    }
  }
  .c1 {
    padding: 20rpx;
    min-height: 200rpx;
    font-size: 14px;
    font-family: PingFangSC, PingFangSC-Regular;
    font-weight: 400;
    text-align: justify;
    color: #2b2b2b;
    line-height: 21px;
  }
}
</style>